<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('visual/register')}">{:lang('可视化墓区')}</a></li>
            <li><a href="{:url('visual/sale')}">墓位信息</a></li>
			<!--<li><a href="{:url('orders/buyer')}">申请人信息</a></li>-->
            <li><a href="{:url('visual/applyer')}">购墓人信息</a></li>
			<li class="active"><a href="{:url('visual/user')}">使用人信息</a></li>
            <li><a href="{:url('visual/chooseGoods')}">商品选购</a></li>
			<li><a href="{:url('visual/signContract')}">合同签订</a></li>
			<li><a href="{:url('visual/orderPay')}">订单支付</a></li>
		</ul>
		<form class="form-horizontal js-ajax-form" action="{:url('Admin/orders/edit_post')}" method="post">
        	<input type="hidden" name="order_id" value="" >
            <input type="hidden" name="ostatus" value="SHIPPING" >
			<fieldset>
            	<div style=" width:515px; margin:0 0 20px 80px; padding:10px 0 20px 20px; border-bottom:1px dashed #0b7ebf">
                <!--	<input type="checkbox"> 寿穴-->
                    <div class="btn btn-primary" id="add_user" style="margin-left:400px;">添加使用人</div>
                </div>
                <div class="control-group">
					<label class="control-label">【壁葬】</label>
                    <div class="controls">
                    	<select name="cate" class="form-control" disabled>
                            <option value="2">双穴</option>
                            <option value="1">单穴</option>
                        </select>
                    </div>
				</div>
				<div class="control-group">
					<label class="control-label">逝者姓名</label>
                    <div class="controls" >
                    	<input type="text" class="form-control" value="">
                    </div>
				</div>
				<div class="control-group">
					<label class="control-label">性别</label>
                    <div class="controls">
                    	<select name="cate" class="form-control">
                            <option value="1">男</option>
                            <option value="2">女</option>
                        </select>
                    </div>
				</div>
				<div class="control-group">
					<label class="control-label">生于</label>
                    <div class="controls">
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 年 
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 月 
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 日 
                    </div>
				</div>
				<div class="control-group">
					<label class="control-label">卒于</label>
                    <div class="controls">
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 年 
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 月 
                    	<select name="cate" style="width:120px" class="form-control">
                            <option value="0">---请选择---</option>
                        </select> 日 
                    </div>
				</div>
                <div class="control-group">
                    <label class="control-label">火化证明</label>
                    <div class="controls">
                        <input type="hidden" name="photos_url" value="">
                        <img height="36" src="" class="preview isHide" id="photos_url_preview" />
						<a class="btn btn-primary" onClick="upload_one_image('身份证上传', '#photos_url')">{:lang("UPLOAD")}</a>
						<span class="form-required">*</span>
                    </div>
                </div>
                <div id="new_user">
                </div>
			</fieldset>
			<div class="form-actions">
            	<div class="btn btn-primary" id="check-btn">保存</div>
				<a class="btn btn-default" id="js-dialog-close"  href="{:url('orders/chooseGoods')}">下一步</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    
	<script type="text/javascript">
	 // 提交订单
	$("#check-btn").click(function(){
		$.post($("form").attr('action'), $("form").serialize(), function(result){
			if(result.state == 'success'){
				alert("保存成功！");
				$('#js-dialog-close').click();
			} else {
				alert(result.info);
			}
		}, 'json');
	});
	var num = 2;
	$("select[name='cate']").change(function(){
		var pnum = $("select[name='cate']").val();
		if(pnum==1){ $("#new_user").html('');}	
		num = pnum;
	})
	// 添加使用人
	$("#add_user").click(function(){
		var count = document.getElementById("new_user").childElementCount;
		console.log(count);
		if(num == 1){
			if(count>=0){alert("最多添加一人");return;}
		}else if(num == 2){
			if(count>0){alert("最多添加两人");return;}
		}
		
		var str = "<div name='now_user'><div class='control-group'>"+
					"<label class='control-label'>逝者姓名</label>"+
                    "<div class='controls' style='margin-top:5px'>"+
                    	"<input type='text' name='tracking_number' value='' class='form-control'>"+
						"<div class='btn btn-primary' name='del_user' style=' margin-left: 100px;'>删除使用人</div>"+
                    "</div>"+
				"</div>"+
				"<div class='control-group'>"+
					"<label class='control-label'>性别</label>"+
                    "<div class='controls'>"+
                    	"<select name='cate' class='form-control'>"+
                            "<option value='1'>男</option>"+
                            "<option value='2'>女</option>"+
                        "</select>"+
                    "</div>"+
				"</div>"+
				"<div class='control-group'>"+
					"<label class='control-label'>生于</label>"+
                    "<div class='controls'>"+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 年 "+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 月 "+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 日 "+
                    "</div>"+
				"</div>"+
				"<div class='control-group'>"+
					"<label class='control-label'>卒于</label>"+
                    "<div class='controls'>"+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 年 "+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 月 "+
                    	"<select name='cate' style='width:120px' class='form-control'>"+
                            "<option value='0'>---请选择---</option>"+
                        "</select> 日 "+
                    "</div>"+
				"</div>"+
				"<div class='control-group'>"+
                    "<label class='control-label'>身份证</label>"+
                    "<div class='controls'>"+
                        "<input type='hidden' name='photos_url' value=''>"+
                        "<img height='36' src='' class='preview isHide' id='photos_url_preview' />"+
						"<a class='btn btn-primary' onClick='upload_one_image('身份证上传', '#photos_url')'>{:lang('UPLOAD')}</a>"+ 
						"<span class='form-required'>*</span>"+
                    "</div>"+
                "</div>";
		$("#new_user").append(str);
	});
	// 删除使用人
	$(document).on("click","[name='del_user']",function(){
		$(this).parents("div[name='now_user']").remove();
	})
    </script>

</body>
</html>